from flask_script import Manager
from flask_migrate import MigrateCommand, Migrate
from info import create_app, db
from flask import Flask, session, current_app
import logging

from flask import Flask
from flask_sqlalchemy import SQLAlchemy
import redis
from flask_wtf.csrf import CSRFProtect
from flask_session import Session
from config import Config

# app = Flask(__name__)


# class Config(object):
#     """工程配置"""
#     DEBUG = True
#     SECRET_KEY = "DSF"
#
#     """数据库配置"""
#     SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/imformation"
#     SQLALCHEMY_TRACK_MODIFICATIONS = False
#
#     """redis配置"""
#     REDIS_HOST = '127.0.0.1'
#     REDIS_PORT = 6379
#
#     """FLASK_SESSION的配置信息"""
#     SESSION_TYPE = "redis"
#     SESSION_USE_SIGNER = True
#     SESSION_REDIS =redis.StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
#     PERMANENT_SESSION_LIFETIME = 86410

#  配置
# app.config.from_object(Config)
# # 配置数据库
# db = SQLAlchemy(app)
# # 配置redis
# redis_store = redis.StrictRedis(host=Config.REDIS_HOST, port=Config.REDIS_PORT)
# # 开启csrf保护
# CSRFProtect(app)
# # 设置session保存位置
# Session(app)

app = create_app('development')

# Flask-script
manager =Manager(app)
# 数据库迁移
Migrate(app, db)
manager.add_command('db', MigrateCommand)


# @app.route('/')
# def index():
#     return 'dnmh'

if __name__ == '__main__':

    # logging.debug("debug的日志信息")
    # logging.info("info的日志信息")
    # logging.warning("warning的日志信息")
    # logging.error("error的日志信息")
    # logging.critical("critical的日志信息")
    manager.run()
